<?php get_header(); ?>

<div class="content-area">
    <main class="site-main">
        <div class="page-header">
            <h1 class="page-title">
                <?php 
                printf(esc_html__('搜索结果: %s', 'my-simple-theme'), '<span>' . get_search_query() . '</span>');
                ?>
            </h1>
        </div>

        <?php if (have_posts()) : ?>
            <div class="posts-list">
                <?php while (have_posts()) : the_post(); ?>
                    <article class="post-item">
                        <?php if (has_post_thumbnail()) : ?>
                            <div class="post-thumbnail">
                                <?php the_post_thumbnail(); ?>
                            </div>
                        <?php endif; ?>
                        <div class="post-content">
                            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                            <div class="post-meta">
                                <?php the_date(); ?> | <?php the_author(); ?>
                            </div>
                            <?php 
                            $content = get_the_content();
                            $excerpt = wp_trim_words($content, 80, '...');
                            echo '<p>' . $excerpt . '</p>';
                            ?>
                        </div>
                    </article>
                <?php endwhile; ?>
            </div>
            
            <?php the_posts_pagination(); ?>
            
        <?php else : ?>
            <div class="no-results">
                <p><?php _e('抱歉，没有找到与您搜索内容匹配的结果。', 'my-simple-theme'); ?></p>
                <?php get_search_form(); ?>
            </div>
        <?php endif; ?>
    </main>
    
    <?php get_sidebar(); ?>
</div>

<?php get_footer(); ?>
